home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
MENU-HOT.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
12KB
|
261 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME MENU-HOT.DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
fTmenuHOT% ( I$(1), LastI% H$(1), O?(1), T%(1), Exet$, SN% )
There are 4 arrays that control fTmenuHOT%. Each of them should be
DIMed from element ZERO and, in there own way, control a particular
part of the function.
I$() Element 0 holds the command string for the menu.
All other items hold the items of the menu.
LastI% IF < 1 THEN LastI% = UBOUND( I$(1) )
H$() IF UBOUND( H$(1) ) > 0 THEN
fHelpLine$ is used to save the area used for item help
item by item help is display with each selection
help area is restored
ELSE
No help is displayed
END IF
O?() This array MUST equal or greater in elements to LastI%
IF O?(i%) > 0 THEN
The item is considered to be in an "ON" status
The value of O?(i%) is the ASCII value of the "HOT-KEY" or
search key (the 1st character of the item)
ELSE
The item is considered to be in an "OFF" status and the user
will not be able to select that/those item(s)
END IF
T%() LastT% = UBOUND( T%(1) )
IF LastT% = 0 THEN
No "tagging" is preformed and the function returns the "hit"
item number
ELSE
The function returns the number of items that are ON
<F-4> will turn all items "OFF"
<F-9> will turn all items "ON"
IF LastT% => LastI% THEN
All items can be tagged (ON/OFF) and <ENTER> will exit
Each item has an array element that will either be ZERO/OFF
or > ZERO/ON
ELSEif LastT% < LastI%
T%(i%) = Tagged Item N° in the order they were tagged
IF LastT% < LastI% THEN
The function automatically exits when the array is full
<F-9> is not functional in this case
END IF
END IF
END IF
Exet$ holds any key-presses you require to exit the function
ie: Exet$ = CHR$(027,0,0,068) would exit on <ESC> and <F-10>
Sn% The element number to start at
ZERO will result in the 1st "ON" item being selected
The following TYPE is loaded from I$(0) with the following results:
' ┌───────────────────┐
'┌┤ GENERAL MENU TYPE ├───────────────────────────
TYPE TmenuTYPE '│└───────────────────┘
SetUp AS BYTE '│ if 0 then TmenuSETUP will be called
Row AS BYTE '│ starting row ( box border if .Brdr > 0 )
Col AS BYTE '│ starting col ( box border if .Brdr > 0 )
Iwide AS BYTE '│ MAX item width
IRows AS BYTE '│ N° if item rows 1, 2, 3, 4 etc
ICols AS BYTE '│ N° of item columns 1, 2, 3, 4 etc
Vert AS BYTE '│ Vertical YES/NO
Wrap AS BYTE '│ Wrap ON/OFF
HKs AS BYTE '│ 0 = NONE : 1 = ALPHA : 2 = HOT-KEY : >2 = TAG
'─────────────────────────┤
AttrN AS BYTE '│ Normal
AttrL AS BYTE '│ Letter HI-light or Tagged Item
AttrB AS BYTE '│ select Bar
AttrO AS BYTE '│ "OFF" item
'─────────────────────────┤
Srow AS BYTE '│ all 3 of these are computed by fTmenuBox$ when
Scol AS BYTE '│ .Srow > 0 else if .Srow = 0 then ignored
Srows AS BYTE '│ values used by fTmenuHOT% if .Srow > 0
Aattr AS BYTE '│ arrow attribute if > 0 else Battr used
'─────────────────────────┤
Brdr AS BYTE '│ Border style SEE: TBoxDRAW
Battr AS BYTE '│ Border attribute
Shdo AS BYTE '│ Shadow style SEE: DrawTShadow
Sattr AS BYTE '│ Shadow attribute
Tpos AS BYTE '│ Title Position
END TYPE '└──────────────┤ 22 bytes ├──────────────────────
─────────────────────────────────────────────────────────────────────────────
───────────────────────── SOME OTHER HAPPENINGs ─────────────────────────────
─────────────────────────────────────────────────────────────────────────────
The function(s) return either:
1) A positive number if <ENTER> was pressed for the selected item
2) A negative number if a "bail out" key was pressed for the "hot" item
3) The number of Tagged items if .HKs > 2
AND
The exiting key-press is in the keyboard buffer
ie: G$ = INKEY$ will gather the key-press for you
IF any of the first 5 bytes of I$(0) = CHR$(0) THEN TmenuSETUP will be
called automatically
NOTE: if HOT KEYS are used remember:
TmenuSETUP also changes/creates the correct printable item STRs
so it cannot be called twice unless the items have been reset to
the "_Hello World" style
A menu can have any, all, or any combination of O?(), T%(), and H$():
To make life just a bit easier there are a series of functions that
automatically allow for menu calling without DIMing the "unused" arrays.
NOTE: Even though fTmenuHOT% is a fully functional routine I would be
extremely hard pressed to conceive of a single menu that would/could
require all of it's properties to be in use at the same time.
Instead, it would be advisable to use either the ready made CALLs as
shown below or to introduce your own "specialized" routines.
eg: A menu that allowed "T"agging would normally have all it's
items in an "ON" status and would generally not use the item by
item "H"elp lines.
In these function names: "H" = item by item Help
"O" = item by item On/Off switching
"T" = item tagging
the presence or absence of these letters explain the required/automatic
portions thereof.
fTmenu% ( I$(), LastI%, H$, Exet$, Sn% )
fTmenuH% ( I$(), LastI%, H$(), Exet$, Sn% )
fTmenuHO% ( I$(), LastI%, H$(), O?(), Exet$, Sn% )
fTmenuHT% ( I$(), LastI%, H$, T%(), Exet$, Sn% )
fTmenuO% ( I$(), LastI%, H$, O?(), T%(), Exet$, Sn% )
fTmenuOT% ( I$(), LastI%, H$, O?(), T%(), Exet$, Sn% ) (questionable use)
fTmenuT% ( I$(), LastI%, H$, T%(), Exet$, Sn% )
fTmenuHOT% ( I$(), LastI%, H$(), O?(), T%(), Exet$, Sn% ) (questionable use)
In the functions above H$ (as a single variable) will cause the help line
to be saved / printed with H$ / and restored upon exiting
─────────────────────────────────────────────────────────────────────────────
──────────────────────────── A SAMPLE PROGRAM ───────────────────────────────
─────────────────────────────────────────────────────────────────────────────
Below is a simple program that will allow you to test the properties
of this menu system.
NOTE: the TYPE is used here to simplify the process but in a working
program I$(0) would hold this information
I$(0) = CHR$(0,0,0,5,3,0,0,0,0,1,31,27,113,25,1,23,1,8,2) + "TITLE"
NOTE: if you are going to use "HOT KEYS" then you will not want to
have more than 26 items (normally)
$endif
$STACK